<!DOCTYPE html>
<html>
<head>
    <title>配置测试</title>
</head>
<body>
    <h1>配置测试页面</h1>
    <div id="config-info"></div>
    <script>
        // 模拟Vue环境变量
        const mockEnv = {
            NODE_ENV: 'development',
            VUE_APP_PROXY_TARGET: 'http://localhost:8080',
            VUE_APP_BASE_API: '',
            VUE_APP_BASE_WSS: ''
        };
        
        // 模拟配置生成逻辑
        const getApiBaseUrl = () => {
            if (mockEnv.VUE_APP_BASE_API) {
                return mockEnv.VUE_APP_BASE_API;
            }
            
            if (mockEnv.NODE_ENV === 'development' && mockEnv.VUE_APP_PROXY_TARGET) {
                return mockEnv.VUE_APP_PROXY_TARGET;
            }
            
            if (mockEnv.NODE_ENV === 'development') {
                return '';
            }
            
            return 'https://adminapi.example.com';
        };
        
        const getWsBaseUrl = () => {
            if (mockEnv.VUE_APP_BASE_WSS) {
                return mockEnv.VUE_APP_BASE_WSS;
            }
            
            if (mockEnv.NODE_ENV === 'development' && mockEnv.VUE_APP_PROXY_TARGET) {
                const proxyTarget = mockEnv.VUE_APP_PROXY_TARGET;
                return proxyTarget.replace(/^https?:\/\//, 'ws://');
            }
            
            if (mockEnv.NODE_ENV === 'development') {
                return `ws://${location.host}`;
            }
            
            return 'wss://adminapi.example.com';
        };
        
        const config = {
            _BASE_API: getApiBaseUrl(),
            _BASE_WSS: getWsBaseUrl()
        };
        
        document.getElementById('config-info').innerHTML = `
            <h2>当前配置:</h2>
            <p><strong>API地址:</strong> ${config._BASE_API}</p>
            <p><strong>WebSocket地址:</strong> ${config._BASE_WSS}</p>
            <p><strong>环境:</strong> ${mockEnv.NODE_ENV}</p>
            <p><strong>代理目标:</strong> ${mockEnv.VUE_APP_PROXY_TARGET}</p>
            <h3>WebSocket连接测试:</h3>
            <p>WebSocket将连接到: ${config._BASE_WSS}/webSocket/notice/testUser/123456</p>
        `;
    </script>
</body>
</html>
